;--------------------------------
;Include Modern UI

  !include "MUI2.nsh"

;--------------------------------
;Variables

  Var StartMenuFolder

;--------------------------------
;General

  ;Name and file
  Name "Minims, Minimal Media Server"
  OutFile "minims_win32.exe"

  ;Default installation folder
  InstallDir "$PROGRAMFILES\Minims"

  ;Request application privileges for Windows Vista
  RequestExecutionLevel admin

;--------------------------------
;Interface Settings


  ;!define MUI_HEADERIMAGE 
  !define MUI_WELCOMEFINISHPAGE_BITMAP "gfx\header.bmp"
  ;!define MUI_HEADERIMAGE_BITMAP "gfx\header.bmp"
  !define MUI_ABORTWARNING

;--------------------------------
;Pages

  !insertmacro MUI_PAGE_WELCOME
  !insertmacro MUI_PAGE_LICENSE "License.txt"
  !insertmacro MUI_PAGE_DIRECTORY

  ;Start Menu Folder Page Configuration
  !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU" 
  !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\Minims" 
  !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
  
  !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder

  !insertmacro MUI_PAGE_INSTFILES
  !insertmacro MUI_PAGE_FINISH

  !insertmacro MUI_UNPAGE_WELCOME
  !insertmacro MUI_UNPAGE_CONFIRM
  !insertmacro MUI_UNPAGE_INSTFILES
  !insertmacro MUI_UNPAGE_FINISH

;--------------------------------
;Languages

  !insertmacro MUI_LANGUAGE "English"

;--------------------------------
;Installer Sections

Section "Base Component"

  SetOutPath "$INSTDIR"
  File "..\minims_win32\bin\Release\minims_lib.dll"
  File "..\minims_win32\bin\Release\minims_win32.exe"

  SetOutPath "$INSTDIR\config"
  File "..\minims_win32\bin\Release\config\config.xml"
  File "..\minims_win32\bin\Release\config\mime-types.xml"


  SetOutPath "$INSTDIR\mencoder"
  File "mencoder.txt"

  ;Store installation folder
  WriteRegStr HKCU "Software\Minims" "" $INSTDIR

  ;Create uninstaller
  WriteUninstaller "$INSTDIR\Uninstall.exe"

  !insertmacro MUI_STARTMENU_WRITE_BEGIN Application

  CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
  CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Minims.lnk" "$INSTDIR\minims_win32.exe"
  CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
  !insertmacro MUI_STARTMENU_WRITE_END

SectionEnd

;--------------------------------
;Uninstaller Section

Section "Uninstall"


  Delete "$INSTDIR\mencoder\mencoder.txt"
  Delete "$INSTDIR\transcodebuf.mpg"
  Delete "$INSTDIR\minims_lib.dll"
  Delete "$INSTDIR\minims_win32.exe"
  Delete "$INSTDIR\Uninstall.exe"

  RMDir "$INSTDIR\mencoder"
  RMDir "$INSTDIR"

  !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
  Delete "$SMPROGRAMS\$StartMenuFolder\Minims.lnk"    
  Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk"
  RMDir "$SMPROGRAMS\$StartMenuFolder"

  DeleteRegKey /ifempty HKCU "Software\Minims"

SectionEnd
